From a92df96600cacfb3c64742aa44010001f4aebf23 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 12 Aug 2019 01:17:32 +0100 Subject: [PATCH] tracefs: Fix potential null dereference in default_file_open() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The "open" operation in struct file_operations is optional, and ftrace_event_id_fops does not set it. In default_file_open(), after all other checks have passed, return 0 if the underlying struct file_operations does not implement open. Fixes: 757ff7244358 ("tracefs: Restrict tracefs when the kernel is …") References: https://bugs.debian.org/934304 Signed-off-by: Ben Hutchings Gbp-Pq: Topic features/all/lockdown Gbp-Pq: Name tracefs-fix-potential-null-dereference-in-default_fi.patch --- fs/tracefs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 338c791c9a0..c59bd8a1998 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -41,6 +41,8 @@ static int default_open_file(struct inode *inode, struct file *filp) return -EPERM; real_fops = dentry->d_fsdata; + if (!real_fops->open) + return 0; return real_fops->open(inode, filp); } -- 2.30.2